<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body onload =changeBgc()>
    <script>

        //rgb颜色
        function getRgbColor(){
            let r = Math.floor(Math.random()*256);
            let g = Math.floor(Math.random()*256);
            let b = Math.floor(Math.random()*256);
            return `rgb(${r},${g},${b})` 
        }

        //16进制颜色
        function get16Color(){
            let r = Math.floor(Math.random()*256);
            let g = Math.floor(Math.random()*256);
            let b = Math.floor(Math.random()*256);
            r.toString(16);
            return `#${ r.toString(16)}${g.toString(16)}${b.toString(16)}` 
        }

       
        
        function changeBgc() {
            document.body.style.backgroundColor = get16Color();
        }
    </script>
</body>
</html>